package com.zqh.synchronizedDemo;

import java.util.concurrent.locks.ReentrantLock;

public class T {
    private int count = 10;
    private Object o = new Object();
    public void m(){
        synchronized (o){
            count--;
            System.out.println(Thread.currentThread().getName()+" count="+count);
        }
    }

    public synchronized void mm(){
        count--;
        System.out.println(Thread.currentThread().getName()+" count="+count);
    }

    public void m1(){
        synchronized (this){
            count--;
            System.out.println(Thread.currentThread().getName()+" count="+count);
        }
    }

    public void m2(){
        synchronized (T.class){
            count--;
            System.out.println(Thread.currentThread().getName()+" count="+count);
        }
    }

    public static void main(String[] args) {
        T t = new T();
        for (int i = 0; i<10; i++){
            new Thread(t::mm).start();
        }
        Thread thread = new Thread(t::m);
        thread.start();
        thread.interrupt();
        Thread.currentThread().getUncaughtExceptionHandler();

    }
}
